def validate(str)
  stack = []
  symbols = { '{' => '}', '[' => ']', '(' => ')' }
  puts "原来是这也"+ symbols.key(")")
  str.each_char do |c|
    stack << c if symbols.key?(c)
    puts symbols.key(c)
    return false if symbols.key(c) && symbols.key(c) != stack.pop
  end
  stack.empty?
end
puts validate("{text}{}(([]))")


def missing_number(array)
  max = array.max
  min = array.min
  (min .. max).to_a - array
end
a = (1 .. 1000).to_a
a.delete((1 .. 1000).to_a.sample)
puts missing_number(a)
